package com.zgjkhis.modules.member.rest;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zgjkhis.logging.aop.log.Log;
import com.zgjkhis.modules.member.domain.Member;
import com.zgjkhis.modules.member.service.MemberService;
import com.zgjkhis.modules.security.security.LoginUserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @date 2018-11-23
 */
@Api(tags = "会员管理：会员管理")
@RestController
@RequestMapping("/member")
public class MemberController {

    private static final String ENTITY_NAME = "memberService";
    private final MemberService memberService;

    public MemberController(MemberService memberService) {
        this.memberService = memberService;
    }


    @Log("查询会员")
    @ApiOperation("查询会员")
    @GetMapping(value = "/getMembers")
//    @PreAuthorize("@el.check('drug:list')")
    public ResponseEntity<Object> getMembers(){
        List<Member> list=memberService.list(Wrappers.<Member>query().lambda().eq(Member::getPharmacyId,LoginUserUtil.getPharmId()).eq(Member::getStatus,0));
        return new ResponseEntity<>(list,HttpStatus.OK);
    }

}
